var nav_fold = {};
var nav_fold_cookie = get_cookie('nav_fold');

jQuery(function($){
	$('div.user_nav .tt em a').click(function(){
		var sb = $(this).parents('div.tt').siblings('div');
		var id = sb.attr('id');
		if($(this).attr('class') == 'fold'){
			$(this).attr('class', 'expand');
			sb.hide();
			nav_fold_save(id, 'add');
		}else{
			$(this).attr('class', 'fold');
			sb.show();
			nav_fold_save(id, 'del');
		}
		return false;
	});

	if(nav_fold_cookie){
		nav_fold_arr = nav_fold_cookie.split(',');
		for(var i in nav_fold_arr){
			nav_fold[nav_fold_arr[i]] = 1;
			$('#'+nav_fold_arr[i]).hide()
			.siblings('div.tt').find('em a').attr('class', 'expand');
		}
	}
	
});

function nav_fold_save(id, o){
	o == o || 'add';
	if(o == 'add'){
		nav_fold[id] = 1;
	}else{
		delete nav_fold[id];
	}
	nav_fold_arr = [];
	for(var id in nav_fold){
		nav_fold_arr.push(id);
	}
	var str = nav_fold_arr.join(',');
	return set_cookie('nav_fold', str, 3153600000);
}

/*function callback_register(params){
	params.url = params.url == '' ? './index.php?frm=user' : params.url;
	params.msg = params.msg || '注册成功';
	callback_common(params);
}*/

/*function callback_login(params) {
	params.url = params.url == '' ? './index.php?frm=user' : params.url;
	params.msg = params.msg || '登录成功';
	callback_common(params);
}*/

function callback_logout(params) {
	params.url = params.url == '' ? './' : params.url;
	params.msg = params.msg || '退出成功';
	callback_common(params);
}

function callback_nologin(params) {
	showmsg_warning('您还未登录，<a href="'+_s['web_dir']+'index.php?mdl=user&do=login">登录</a>', {title:'警告'});
	setTimeout(function(){
		window.location.href = _s['web_dir']+'index.php?mdl=user&do=login';
	}, params.ttl);
}